﻿/*
*	冰火家族萬能NPC
*
*
*
*
*
*/
var x = "#fEffect/CharacterEff/1112949/0/0#";//高音譜記號
var kk = "#fEffect/BasicEff/MainNotice/Boss/Default/0#";//BOSS
var c = "#fEffect/CharacterEff/1032063/0/0#";//"#fUI/UIMiniGame/starPlanetRPS/heart#";//愛心
var cmark = "#fUI/UIMiniGame/starPlanetRPS/heart#";//愛心
var lb = "#fEffect/ItemEff/1112811/0/0#";//藍色小光
var b = "#fEffect/CharacterEff/Shaman/1#";//超萌熊熊
var cat = "#fEffect/CharacterEff/Shaman/4#";//超萌喵咪
var leaf = "#fUI/Basic.img/Cursor/18/0#";
var selec;
var status;
var item_p;
var price = 1;
		
var choice = Array(
		Array(1,5,10,"1 小時",true),
		Array(3,10,20,"3 小時",true),
		Array(6,20,40,"6 小時",true),
		Array(24,30,50,"1 天  ",true),
		Array(172,100,150,"7 天  ",true)
);
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {

    if (mode == 0) {
	cm.dispose();
	return;
    } else if (mode == 1){
	status++;
    } else {
	status--;
    }

    switch (status) {
        case 0: 
			text = "\t  "+c+"#fn华文行楷##fs30##e#k #b寵物全圖 " +c+ "\r\n#fs12##fn宋体#";
			text += "\r\n\r\n\t\t#r楓幣 全圖撿:\r\n";
			for (var i = 0; i < choice.length; i++) {
				if (choice[i][4]) { // 如果允许显示
					text += "\t\t\t#d#L" + i + "# " + cmark +" #r" + choice[i][3] + "( "+ choice[i][1] +" 贊助點)#l\r\n";
				}
			}
			text += "\r\n\r\n\t\t#r楓幣+道具 全圖撿:\r\n";
			for (var i = 0; i < choice.length; i++) {
				if (choice[i][4]) { // 如果允许显示
					text += "\t\t\t#d#L" + (i+choice.length) + "# " + cmark +" #r" + choice[i][3] + "( "+ choice[i][2] +" 贊助點)#l\r\n";
				}
			}
			text += "\r\n\r\n\t\t   #L999#" + leaf +"#fn华文行楷##fs22##e#r回上一頁#l"
			text += "\r\n\r\n  " +c+c+c+c+c+c;
			cm.sendSimple(text);
            break;
        case 1: //
			switch (selection){
				case 999://回上一頁
					cm.dispose();
					cm.openNpc(1052253, 3);
					break;
				default:
					selec = selection;
					if(selec > 3){
						item_p = true;
					}
					if(item_p){
						selec -= choice.length;
						price = 2;
					}
					text = "#fs20##e#d您確定要購買寵物全圖撿#r " + choice[selec][3]+"\r\n\r\n" + (item_p?"#v4430005##z4430005# 花費:":"#v4430004##z4430004# 花費:") + choice[selec][price] +" 贊助點\r\n\r\n確認後將無法返回!";
					cm.sendYesNo(text);
					break;
			}
            break;
		case 2:
			if (selec >= 0 && selec < choice.length && choice[selec] != null) {
				if(cm.getRMB()>=choice[selec][price]){
					
					text = "#e恭喜您獲得了#fs20#\r\n#r" + (item_p?"#v4430005##z4430005#":"#v4430004##z4430004#") + " 為期 " + choice[selec][3];
					if(cm.canHold(4430005,1)){
					if(item_p && !cm.haveItem(4430005, 1)){
						cm.gainItemPeriod(4430005, 1, choice[selec][0] * 60 * 60 * 1000);
						cm.setRMB((cm.getRMB()-choice[selec][price]));
						text += "\r\n\r\n#b#fs15#您的贊助點餘額為 : #r" + cm.getRMB() + " #b點";
					}else if(!item_p && !cm.haveItem(4430004, 1)){
						cm.gainItemPeriod(4430004, 1, choice[selec][0] * 60 * 60 * 1000);
						cm.setRMB((cm.getRMB()-choice[selec][price]));
						text += "\r\n\r\n#b#fs15#您的贊助點餘額為 : #r" + cm.getRMB() + " #b點";
					}else
						text = "您已經擁有寵物全圖撿道具!!";
					}else{
						text = "您的背包已滿!!"
					}
					cm.sendOk(text);
					cm.dispose();
				}else{
					cm.sendOk("您的贊助點不足!");
					cm.dispose();
				}
			} else {
				cm.sendOk("傳送出現錯誤 請聯繫管理員");
				cm.dispose();
			}
			break;
        default:
			cm.sendOk("發生錯誤，請聯繫管理員!");
			cm.dispose();
			break;
    }
}
